package suites.as3Core.utilites.bitwise.cases
{
	import com.powwow.as3Core.utilites.bitwise.isAtLeastOneBitSet;

	import org.flexunit.asserts.assertEquals;

	public class BitwiseIsAtLeastOneBitSetTest
	{

		[Before]
		public function setUp():void
		{
		}

		[After]
		public function tearDown():void
		{
		}

		[BeforeClass]
		public static function setUpBeforeClass():void
		{
		}

		[AfterClass]
		public static function tearDownAfterClass():void
		{
		}


		private static const ALL_ALLOWED_MASK:uint=0xFFFFFFFF;

		[Test]
		public function test_zero_zero():void
		{
			//given 
			const flags:uint=0;
			const bits:uint=0;
			//when 
			const result:Boolean=isAtLeastOneBitSet(flags, bits);
			//then
			assertEquals(false, result);
		}

		[Test]
		public function test_zero_nonzero():void
		{
			//given 
			const flags:uint=0;
			const bits:uint=50;
			//when 
			const result:Boolean=isAtLeastOneBitSet(flags, bits);
			//then
			assertEquals(false, result);
		}

		[Test]
		public function test_nonzero_zero():void
		{
			//given 
			const flags:uint=50;
			const bits:uint=0;
			//when 
			const result:Boolean=isAtLeastOneBitSet(flags, bits);
			//then
			assertEquals(false, result);
		}

		[Test]
		public function test_allAllowedMask_with_1():void
		{
			//given 
			const flags:uint=ALL_ALLOWED_MASK;
			const bits:uint=1;
			//when 
			const result:Boolean=isAtLeastOneBitSet(flags, bits);
			//then
			assertEquals(true, result);
		}

		[Test]
		public function test_intersected1():void
		{
			//given 
			const mask:uint=parseInt("10001110001", 2);
			const bits:uint=parseInt("00000100000", 2);
			//when 
			const result:Boolean=isAtLeastOneBitSet(mask, bits);
			//then
			assertEquals(true, result);
		}

		[Test]
		public function test_intersected2():void
		{
			//given 
			const mask:uint=parseInt("10001110001", 2);
			const bits:uint=parseInt("00000110000", 2);
			//when 
			const result:Boolean=isAtLeastOneBitSet(mask, bits);
			//then
			assertEquals(true, result);
		}

		[Test]
		public function test_intersected3():void
		{
			//given 
			const mask:uint=parseInt("10001110001", 2);
			const bits:uint=parseInt("00011111000", 2);
			//when 
			const result:Boolean=isAtLeastOneBitSet(mask, bits);
			//then
			assertEquals(true, result);
		}

		[Test]
		public function test_nonintersect():void
		{
			//given 
			const mask:uint=parseInt("10000000001", 2);
			const bits:uint=parseInt("00011111000", 2);
			//when 
			const result:Boolean=isAtLeastOneBitSet(mask, bits);
			//then
			assertEquals(false, result);
		}
	}
}
